const queryStr = require('querystring');
const crypto = require('crypto');
const { authToken } = require('../config/config')

module.exports = (ctx) => {
  let { signature, timestamp, nonce, echostr } = ctx.query;
  var params = [authToken, timestamp, nonce]
  let url = params.sort().join('');
  let mySign = crypto.createHash('sha1').update(url).digest('hex');
  if (mySign === signature) {
    ctx.body = echostr;
  } else {
    ctx.body = "非法请求";
  }
}